package com.raising.sc;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 配置中心客户端
 * @author GaoYuan
 * @date 2018/3/29 下午2:58
 *
 * SpringBootApplication //springboot 启动器
 * RestController        //表示rest服务
 * EnableDiscoveryClient //服务发现
 * RefreshScope          //这个注释必须要加上，不然无法触发配置文件的刷新
 */
@SpringBootApplication
@RestController
@EnableDiscoveryClient
@RefreshScope
public class ConfigClientApplication {
    public static void main( String[] args ) {
        SpringApplication.run(ConfigClientApplication.class,args);
    }

    /** 返回从配置中心读取的foo变量的值 这里用来测试config的动态刷新特性 */
    @Value("${foo}")
    String foo;

    @RequestMapping(value = "/hi")
    public String hi(){
        return foo;
    }
}
